package main

import (
	"fmt"
	"unicode/utf8"
)

func main() {
	s := "Hi 世界"  // 3个ASCII字符，2个中文字符
	fmt.Println(len(s))
	fmt.Println(utf8.RuneCountInString(s))

	for i := 0; i < len(s); {
		r, size := utf8.DecodeRuneInString(s[i:])
		fmt.Printf("%d\t%c\t%d\n", i, r, size)
		i += size
	}

	var n uint
	for range s {
		n++
	}
	fmt.Println(n)

	for i, r := range s {
		fmt.Printf("%d\t%c\t%d\n", i, r, len(string(r)))
	}
}